from langchain.chains.llm import LLMChain
from langchain_core.prompts import PromptTemplate
from langchain_openai import OpenAI

# 大模型
llm = OpenAI(
    api_key="sk-VowKQBUMIkSND8WScNJtDLqf3FyqWHQ43LMVUXH1m6GZaopA",
    base_url="https://ai.nengyongai.cn/v1",
    temperature=0
)


def test():
    # 提示词
    template = "{flower}的花语是?"
    prompt = PromptTemplate.from_template(template);

    # chain
    llm_chain = LLMChain(
        llm=llm,
        prompt=prompt
    )

    # 调用chain
    result = llm_chain("玫瑰")
    print(result)
